package com.manage.sysuser.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.manage.base.service.impl.BaseServiceImpl;
import com.manage.config.model.Config;
import com.manage.sysuser.dao.ISysUserDao;
import com.manage.sysuser.model.RoleUserInfo;
import com.manage.sysuser.model.SysUser;
import com.manage.sysuser.service.ISysUserService;

@Service("sysUserService")
@Transactional
public class SysUserServiceImpl extends BaseServiceImpl<SysUser>implements ISysUserService {

	@Autowired
	private ISysUserDao dao;

	@Override
	public List<SysUser> selectList(SysUser sysUser) {
		List<SysUser> list = dao.selectList(sysUser);
		return list;
	}

	@Override
	public int op(SysUser sysUser) {
		dao.op(sysUser);
		return Config.SUCCESS;
	}
	@Override
	public int add(SysUser sysUser){
		dao.add(sysUser);
		return Config.SUCCESS;
	}

	@Override
	public SysUser selectOne(SysUser sysUser) {
		return dao.selectOne(sysUser);
	}
	@Override
	public int delete (SysUser sysUser) {
		return dao.delete(sysUser);
	}
	@Override
	public int update(SysUser sysUser){
		return dao.update(sysUser);
	}

	@Override
	public int addRoleUser(SysUser sysUser) {
		RoleUserInfo roleUserInfo=new RoleUserInfo();
		roleUserInfo.setUserId(sysUser.getUserId());
		roleUserInfo.setRoleId(2);
		return dao.addRoleUser(roleUserInfo);
	}

	@Override
	public int selectTotalCount(SysUser sysUser) {
		return dao.selectTotalCount(sysUser);
	}

}
